<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 执行操作后的变量值 -->
    <script>
      var finalValueAfterOperations = function (operations) {
        let X = 0
        for (let i = 0; i < operations.length; i++) {
          operations[i].indexOf('+') > -1 ? (X += 1) : (X += -1)
        }
        return X
      }
      console.log(finalValueAfterOperations(['--X', 'X++', 'X++']))
    </script>
  </body>
</html>
